package org.cardcopier.file;

import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.logging.Logger;

public class FileLocationComparator {

	private static final Logger LOGGER = Logger.getLogger(FileLocationComparator.class.getName());

	private final FileLocation source;
	private final FileLocation destination;

	public FileLocationComparator(FileLocation source, FileLocation destination) {
		this.source = source;
		this.destination = destination;
	}
	
	public List<FileState> listFiles(Comparator<File> order) {
		List<File> files = source.getFiles();
		Collections.sort(files, order);
                
                List<FileState> fileStates = new ArrayList<FileState>();
		for (File file : files) {
                    FileState fileState = new FileState(file, new File(destination.getDirectory(), file.getName()));
                    fileStates.add(fileState);
		}
                return fileStates;
	}
	
        public FileLocation getSource() {
            return source;
        }
        
}
